package com.controller;




import com.controller.reqdto.*;
import com.controller.template.ResultHelper;

import com.controller.template.ResultInfo;
import com.service.GroupService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Random;


/**
 * @author ruiwen
 */
@RestController
@Api(tags = "群组模块")
@RequestMapping("/group")
@CrossOrigin
@Slf4j
public class GroupController extends ResultHelper {
    @Resource
    GroupService groupService;

    /**
     * 新增群组
     *
     * @param
     * @return
     */
    @ApiOperation("新增群组")
    @PostMapping("/addGroup")
    public ResultInfo addGroup(@RequestBody  GroupAddParam groupAddParam) {
        return successResultInfo(groupService.addGroup(groupAddParam));
    }


    /**
     * 新增群组
     *
     * @param
     * @return
     */
    @ApiOperation("修改群组")
    @PostMapping("/updateGroup")
    public ResultInfo updateGroup(@RequestBody GroupUpdateParam updateParam) {
        return successResultInfo(groupService.updateGroup(updateParam));
    }

    /**
     * 新增群组
     *
     * @param
     * @return
     */
    @ApiOperation("分页查询群组")
    @PostMapping("/queryGroup")
    public ResultInfo queryGroup(@RequestBody GroupQueryParam queryParam) {

        return successResultInfo(groupService.queryGroup(queryParam));
    }

    /**
     * 新增群组
     *
     * @param
     * @return
     */
    @ApiOperation("删除群组")
    @PostMapping("/deleteGroup")
    public ResultInfo deleteGroup( String groupId) {
        return successResultInfo(groupService.deleteGroup(groupId));
    }



    /**
     * 加入群组
     *
     * @param
     * @return
     */
    @ApiOperation("加入群组")
    @PostMapping("/joinGroup")
    public ResultInfo joinGroup( @RequestBody  JoinGroupParam joinGroupParam) {
        return successResultInfo(groupService.joinGroup(joinGroupParam));
    }

    /**
     * 退出群组
     *
     * @param
     * @return
     */
    @ApiOperation("退出群组")
    @PostMapping("/exitGroup")
    public ResultInfo exitGroup( @RequestBody  ExitGroupParam exitGroupParam) {
        return successResultInfo(groupService.exitGroup(exitGroupParam));
    }




}
